package com.zxk.app;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import lombok.Getter;
import lombok.Setter;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * 上下文内容
 *
 * @author: 舟小亢
 * @date: 2024-11-13 0:10
 */
public class ContextHolder {

    /**
     * 队长选择下拉框列表
     */
    private static ObservableList<String> captainItems = FXCollections.observableArrayList();

    /**
     * 队长线程名
     */
    @Getter
    @Setter
    private static volatile String captainName = "";


    /**
     * 最后一个副本任务名
     */
    @Getter
    @Setter
    private static String lastInstanceTaskName = "";

    /**
     * 副本任务执行结束标志
     */
    @Getter
    @Setter
    private static AtomicBoolean instanceTaskDone = new AtomicBoolean(false);

    /**
     * 副本任务结束后是否退队
     */
    @Getter
    @Setter
    private static AtomicBoolean isQuitTeamAfterInstance = new AtomicBoolean(false);

    public static synchronized ObservableList<String> getCaptainItems(){
        return captainItems;
    }

    public static synchronized boolean addCaptainItems(String items){
        return captainItems.add(items);
    }

    public static synchronized boolean updateCaptainItems(Collection<String> itemList){
        captainItems.clear();
        return captainItems.addAll(itemList);
    }

}
